//引入路由的ap1

import {createRouter,createWebHashHistory} from 'vue-router'

//引入页面
const Home = () => import("../views/Home.vue")
const About = () => import("../views/About.vue")
const UserCenter = () => import("../views/user-center/index.vue");
const UserProfile = () => import("../views/user-center/Profile.vue");
const UserSettings = () => import("../views/user-center/Settings.vue");
const ElementTest = () =>import("../views/ElementTest.vue")
const ListDemo = () =>import("../views/ListDemo.vue")

const VuexPage = () => import("../views/Vuex.vue");

//404
const NotFound = () => import("../views/404.vue");
const Register = ()=> import("../views/Register.vue")
const Dialog = ()=>import("../views/Dialog.vue")
const Message = ()=>import("../views/Message.vue")
const AccountList = ()=>import("../views/AccountList.vue")
//路由配置

const rg = [
    {path:'/',redirect:'/home'},
    {path:'/home', name:'home', component: Home},
    {path:'/about', name:'about', component: About},
    {path:'/element', name:'element', component: ElementTest},
    {path:'/list-demo', name:'list-demo', component: ListDemo},
    {path:'/register', name:'register',component: Register},
    {path:'/dialog',name:'dialog',component:Dialog},
    {path:'/message',name:'message',component:Message},
    {path:'/accountList',name:'accountList',component:AccountList},
    {
        path:"/user",
        name:"userCenter",
        component:UserCenter,
        redirect:'/user/profile',
        children:[
            {
                path:"profile",
                name:"profile",
                component:UserProfile
            },
            {
                path:"settings",
                name:"settings",
                component:UserSettings
            },
        ]
    },
    {
        path:'/:pathMatch(.*)*',
        name:'NotFound',
        component:NotFound
    },
    //路由配置
    {path:'/vuex', name:'vuex', component: VuexPage},
]

//创建实例化路由
const router = createRouter({
    history: createWebHashHistory(),
    routes: rg
})

//对外暴露实例化路由对象
export default router